package com.yan.jingdongshop.domain;

import java.io.Serial;
import java.io.Serializable;

/**
 * @author taoge
 * @Date 2024/8/2 18:38
 * @Description
 */
public class Goods implements Comparable<String>, Serializable {
    @Serial
    private static final long serialVersionUID = -3205751608073350878L;

    private String id;
    private String name;
    private Double price;
    private String colour;
    private Integer dimension;
    private Integer stoke;

    public Goods(String id, String name, Double price, String colour, Integer dimension, Integer stoke) {
        this.id = id;
        this.name = name;
        this.price = price;
        this.colour = colour;
        this.dimension = dimension;
        this.stoke = stoke;
    }

    public Goods() {

    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Double getPrice() {
        return price;
    }

    public void setPrice(Double price) {
        this.price = price;
    }

    public String getColour() {
        return colour;
    }

    public void setColour(String colour) {
        this.colour = colour;
    }

    public Integer getDimension() {
        return dimension;
    }

    public void setDimension(Integer dimension) {
        this.dimension = dimension;
    }

    public Integer getStoke() {
        return stoke;
    }

    public void setStoke(Integer stoke) {
        this.stoke = stoke;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Goods goods = (Goods) o;

        if (id != null ? !id.equals(goods.id) : goods.id != null) return false;
        if (name != null ? !name.equals(goods.name) : goods.name != null) return false;
        if (price != null ? !price.equals(goods.price) : goods.price != null) return false;
        if (colour != null ? !colour.equals(goods.colour) : goods.colour != null) return false;
        if (dimension != null ? !dimension.equals(goods.dimension) : goods.dimension != null) return false;
        return stoke != null ? stoke.equals(goods.stoke) : goods.stoke == null;
    }

    @Override
    public int hashCode() {
        int result = id != null ? id.hashCode() : 0;
        result = 31 * result + (name != null ? name.hashCode() : 0);
        result = 31 * result + (price != null ? price.hashCode() : 0);
        result = 31 * result + (colour != null ? colour.hashCode() : 0);
        result = 31 * result + (dimension != null ? dimension.hashCode() : 0);
        result = 31 * result + (stoke != null ? stoke.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        return "Goods{" +
                "id='" + id + '\'' +
                ", name='" + name + '\'' +
                ", price=" + price +
                ", colour='" + colour + '\'' +
                ", dimension=" + dimension +
                ", stoke=" + stoke +
                '}';
    }

    @Override
    public int compareTo(String o) {
        if(this.id.compareTo(o) > 0){
            return 1;
        }else if(this.id.compareTo(o) < 0){
            return -1;
        }else{
            return 0;
        }
    }
}
